<?php
namespace app\plus\controller;

use think\Controller;

class HelpController extends Controller
{
    //二维码显示
    public function qrcode()
    {
        $qrCode = new \Endroid\QrCode\QrCode();
        $qtext  = $this->request->param('qtext');
        $qtext  = str_decode($qtext);
        if ($qtext) {
            $qrCode->setText($qtext)
                ->setSize(300)
                ->setPadding(10)
                ->setErrorCorrection('high')
                ->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0])
                ->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0])
                ->setImageType(\Endroid\QrCode\QrCode::IMAGE_TYPE_PNG);
            $qrCode->render();
        }
    }

    /**
     * 获取快递信息
     */
    public function getExpress()
    {
        $type   = $this->request->param('type');
        $postid = $this->request->param('postid');
        $data   = send_http('http://www.kuaidi100.com/query', ['type' => $type, 'postid' => $postid]);
        $data   = json_decode($data, true);
        return $data;
    }

}